import React, { Component } from 'react'
import { connect } from 'dva';
import Link from 'umi/link';
import { Form } from 'antd';
import { SearchRow, SearchCol, SearchButton } from '@/styled/form';

import { UmiComponentProps, SearchComponentProps } from '@/common/type';

interface P {
  dict?: any;
  cond?: {
    ownerId: string;
    pageNum: number;
    pageSize: number;
  };
  loading?: true;
  location?: Array<any>;
}

type Props = P & UmiComponentProps & SearchComponentProps;

@connect(({ device_things_host, loading }) => ({
  dict: device_things_host.dict || {},
  cond: device_things_host.cond || {},
}))
class Search extends Component<Props, any> {

  showUpload = (v) => {
    const { dispatch } = this.props;
    dispatch({ type: 'devices/queryTemple', payload: { type: 'device_things_host' } })
  }
  
  render() {

    return (
      <Form>
        <SearchRow style={{ paddingRight: '40px' }}>
          <SearchCol key={4} span={24} >
            <SearchRow type="flex" justify="end"> 
            <SearchButton icon="select" onClick={this.showUpload}>导入</SearchButton>
              <Link to='/data/device_things_host/new' style={{ marginLeft: '10px' }}>
                <SearchButton icon='plus' type="primary">新增</SearchButton>
              </Link>
            </SearchRow>
          </SearchCol>
        </SearchRow>
      </Form>
    );
  }
}

const SearchS = Form.create<Props>()(Search);
export default SearchS;
